package com.csweimei.rentmanagementtreasure.tenant.viewModel;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.csweimei.rentmanagementtreasure.base.AppConfig;
import com.csweimei.rentmanagementtreasure.http.entity.TabTwoScheduleListBean;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.customer.CustomerDetailActivity;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.customer.CustomerInfoActivity;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.house.HouseDetailHzActivity;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.house.HouseDetailZzActivity;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class TabTwoItemVM extends MultiItemViewModel {
    public TabTwoItemVM(@NonNull BaseViewModel viewModel) {
        super(viewModel);
    }

    public ObservableField<TabTwoScheduleListBean.DataDTO > entity = new ObservableField<>();

    public void setData(TabTwoScheduleListBean.DataDTO bean) {
        entity.set(bean);
    }

    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bundle;
            switch (entity.get().getScheduleType()){
                case "跟进房源":
                    bundle = new Bundle();
                    bundle.putInt(AppConfig.BUNDLE_KEY,entity.get().getHousingID());
                    if (entity.get().getCategory().equals("合租")){
                        viewModel.startActivity(HouseDetailHzActivity.class,bundle);
                    }else {
                        viewModel.startActivity(HouseDetailZzActivity.class,bundle);
                    }

                    break;
                case "跟进客户":
                    bundle = new Bundle();
                    bundle.putString(AppConfig.BUNDLE_KEY,entity.get().getSid());
                    bundle.putString(AppConfig.BUNDLE_KEY2,"person");
                    viewModel.startActivity(CustomerInfoActivity.class,bundle);
                    break;
                default:
//                    bundle = new Bundle();
//                    bundle.putString(AppConfig.BUNDLE_KEY,entity.get().getSid());
//                    bundle.putString(AppConfig.BUNDLE_KEY2,"person");
//                    viewModel.startActivity(CustomerInfoActivity.class,bundle);
                    break;
            }
        }
    });
}
